package cn.kgc.springmvc.controller;

import cn.kgc.springmvc.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author: mosin
 * @version: v1.0  2022/5/5
 * get      查询
 * post     添加
 * put     更新
 * delete   删除
 */
@Controller
@RequestMapping("/restful")
public class RestfulController {

    //@GetMapping("/user/{id}")
    @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    public String  selectUser(@PathVariable  Integer id){
        System.out.println("id = " + id);
        System.out.println("/user RequestMethod.GET");
        return  "success";
    }

    //@PostMapping
    @RequestMapping(value = "/user",method = RequestMethod.POST)
    public String addtUser(User user){
        System.out.println("user = " + user);
        System.out.println("/user RequestMethod.POST");
        return  "success";
    }

    //@PutMapping
    @RequestMapping(value = "/user",method = RequestMethod.PUT)
    public String updateUser(User user){
        System.out.println("user = " + user);
        System.out.println("/user RequestMethod.PUT");
        return  "success";
    }

    //@DeleteMapping
    @RequestMapping(value = "/user/{id}",method = RequestMethod.DELETE)
    public String deleteUser(@PathVariable Integer id){
        System.out.println("id = " + id);
        System.out.println("/user RequestMethod.DELETE");
        return  "success";
    }


    @RequestMapping("/user/add")
    public String addUser(User user){
        System.out.println("user = " + user);
        return  "success";
    }




}
